import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import Pages from "vite-plugin-pages";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [
    react(),
    Pages({
      dirs: "src/pages",
      exclude: ["**/components/*.tsx"],
    }),
  ],
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
    },
  },
  server: {
    port: 8000,
    open: true,
    hmr: true, // 启用热更新
    // proxy: {
    //   "/api": {
    //     target: "http://localhost:8001",
    //     changeOrigin: true,
    //     ws: true,
    //     rewrite: (path: string) => path.replace(/^\/api/, ""),
    //   },
    // },
  },
});
